package com.insurance.controller;

import cn.hutool.db.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;


/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2020/11/02 14:15
 * Description:
 * Version: V1.0
 */
@Component
public class Producer {
    @Autowired(required = false)
    private JmsTemplate jmsTemplate;

    @Autowired(required = false)
    private Destination textDestination;
    public void sendTextMessage(final String text){
        jmsTemplate.send(textDestination, new MessageCreator() {

            @Override
            public Message createMessage(javax.jms.Session session) throws JMSException {
                return session.createTextMessage(text);
            }

        });
    }
}
